<template>
  <div>
    <!-- 产品添加 -->
    <el-drawer title="产品添加" :visible.sync="addShopDrawer.addShopDrawerFlg" :with-header="false" size="85%">
      <div class="nameDrawer">
        <el-form label-position="left" class="shopForm" ref="shopForm" :model="shopForm" label-width="120px" :disabled="formDisabled">
          <el-form-item label="产品名称">
            <el-input v-model="shopForm.product_name" placeholder="请填写产品名称"></el-input>
          </el-form-item>
          <el-form-item label="产品分类">
            <el-cascader :options="shopForm.priductClass" v-model="shopForm.priductClassId" clearable :style="{ width: '100%' }"
                         @change="priductClassChange"></el-cascader>
          </el-form-item>
          <el-form-item label="产品介绍图">
            <el-upload ref="upload" action="" :before-upload="IMG_upload" list-type="picture-card" :file-list="shopForm.productImgView">
              <i slot="default" class="el-icon-plus"></i>
              <div slot="file" slot-scope="{file}">
                <img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
                <span class="el-upload-list__item-actions">
                  <span class="el-upload-list__item-preview" @click="IMG_handlePictureCardPreview(file)">
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span v-if="!IMG_disabled" class="el-upload-list__item-delete" @click="IMG_handleRemove(file)">
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
          </el-form-item>
          <el-form-item label="放款机构名称">
            <el-input v-model="shopForm.loanMechanismName" placeholder="请输入放款机构名称"></el-input>
          </el-form-item>
          <el-form-item label="借款人年龄">
            <el-slider v-model="shopForm.userAge" :marks="shopForm.userAgeMarks" range :step="1" :min="18" :max="100">
            </el-slider>
          </el-form-item>
          <el-form-item label="进件条件" v-if="classIdFlg == '4'">
            <el-input type="textarea" v-model="shopForm.importCondition" autosize></el-input>
          </el-form-item>
          <el-form-item label="公积金个缴" v-if="classIdFlg == '4'">
            <el-slider v-model="shopForm.accumulationFundView" :format-tooltip="accumulationFundTooltip" show-input :max="10000">
            </el-slider>
          </el-form-item>
          <el-form-item label="社保缴存基数" v-if="classIdFlg == '4'">
            <el-slider v-model="shopForm.socialSecurityView" :format-tooltip="socialSecurityTooltip" show-input :max="10000"> </el-slider>
          </el-form-item>
          <el-form-item label="表现公里数" v-if="classIdFlg == '2'">
            <el-input v-model="shopForm.kilometreNum" type="number" placeholder="请输入表现公里数 例如：10000">
              <template slot="append">公里</template>
            </el-input>
          </el-form-item>
          <el-form-item label="工资" v-if="classIdFlg == '4'">
            <el-input v-model="shopForm.wages" placeholder="请输入打卡工资 例如：工作12个月以上，打卡5000以上"></el-input>
          </el-form-item>
          <el-form-item label="房龄" v-if="classIdFlg == '1'">
            <el-input v-model="shopForm.room" placeholder="请输入房龄 例如：30年 或者 25-30年"></el-input>
          </el-form-item>
          <el-form-item label="车型要求" v-if="classIdFlg == '2'">
            <el-input type="textarea" v-model="shopForm.modelrq" autosize placeholder="请输入车型要求"></el-input>
          </el-form-item>
          <el-form-item label="GPS" v-if="classIdFlg == '2'">
            <el-input v-model="shopForm.carGPS" placeholder="请输入GPS收费情况"></el-input>
          </el-form-item>
          <el-form-item label="抵押年限" v-if="classIdFlg == '2' || classIdFlg == '1'">
            <el-input v-model="shopForm.mortgageYears" placeholder="请输入抵押年限 例如：5年"></el-input>
          </el-form-item>
          <el-form-item label="利率">
            <el-radio-group v-model="shopForm.interestRate" style="width: 100%">
              <el-row class="shopFormMar">
                <el-col :span="3">
                  <el-radio label="1">年利率</el-radio>
                </el-col>
                <el-col :span="12">
                  <el-slider v-model="shopForm.interestRateYearView" :format-tooltip="interestRateYearViewTooltip" :step="0.01" :max="10" show-input>
                  </el-slider>
                </el-col>
              </el-row>
              <el-row class="shopFormMar">
                <el-col :span="3">
                  <el-radio label="2">日利率</el-radio>
                </el-col>
                <el-col :span="12">
                  <el-slider v-model="shopForm.interestRateMonthView" :format-tooltip="interestRateMonthViewTooltip" :step="0.01" :max="10"
                             show-input>
                  </el-slider>
                </el-col>
              </el-row>
            </el-radio-group>
            <el-row class="shopFormMar">
              <el-input v-model="shopForm.interestRateText" placeholder="有关利率的其他说明"></el-input>
            </el-row>
          </el-form-item>
          <el-form-item label="立项" v-if="classIdFlg == '1'">
            <el-input v-model="shopForm.projectApproval" placeholder="请输入立项说明"></el-input>
          </el-form-item>
          <el-form-item label="额度上限">
            <el-row :gutter="6">
              <el-col :span="6">
                <el-input type="number" v-model="shopForm.quotaMin" placeholder="请输入最小额度">
                  <template slot="append">万</template>
                </el-input>
              </el-col>
              <el-col :span="6">
                <el-input type="number" v-model="shopForm.quotaMax" placeholder="请输入最大额度">
                  <template slot="append">万</template>
                </el-input>
              </el-col>
              <el-col :span="10">
                <el-input v-model="shopForm.quotaText" placeholder="请输入额度说明（选填）"></el-input>
              </el-col>
            </el-row>
          </el-form-item>
          <el-form-item label="期限" v-if="classIdFlg == '3' || classIdFlg == '5'">
            <el-input v-model="shopForm.term" placeholder="请输入期限 例如：12期 或者 3/6/12期"></el-input>
          </el-form-item>
          <el-form-item label="还款方式">
            <el-checkbox-group v-model="shopForm.repaymentType" style="width: 100%">
              <el-row class="shopFormMar" v-for="item in shopForm.repaymentTypeArr" :key="item.value">
                <el-col :span="3">
                  <el-checkbox :label="item.value">{{item.name}}</el-checkbox>
                </el-col>
                <el-col :span="12">
                  <el-input v-model="item.text" placeholder="说明"></el-input>
                </el-col>
              </el-row>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="放款">
            <el-input v-model="shopForm.loan" placeholder="请输入放款 例如：3天到5天 或 受托支付 或 个人"></el-input>
          </el-form-item>
          <el-form-item label="申请人要求" v-if="classIdFlg == '3' || classIdFlg == '5'">
            <el-input type="textarea" autosize v-model="shopForm.applicantRQ" placeholder="请输入申请人要求"></el-input>
          </el-form-item>
          <el-form-item label="企业及开票" v-if="classIdFlg == '3' || classIdFlg == '5'">
            <el-input type="textarea" autosize v-model="shopForm.enterpriseBilling" placeholder="请输入企业及开票"></el-input>
          </el-form-item>
          <el-form-item label="目标企业" v-if="classIdFlg == '3' || classIdFlg == '5'">
            <el-input type="textarea" autosize v-model="shopForm.targetEnterprise" placeholder="请输入目标企业"></el-input>
          </el-form-item>
          <el-form-item label="行业限制" v-if="classIdFlg == '3' || classIdFlg == '5'">
            <el-input type="textarea" autosize v-model="shopForm.industryLimit" placeholder="请输入行业限制"></el-input>
          </el-form-item>
          <el-form-item label="征信要求">
            <el-input type="textarea" autosize v-model="shopForm.creditInvestigation" placeholder="请输入征信要求"></el-input>
          </el-form-item>
          <el-form-item label="负债计算方法" v-if="classIdFlg == '4'">
            <el-input type="textarea" autosize v-model="shopForm.liabilities" placeholder="请写明计算方式"></el-input>
          </el-form-item>
          <el-form-item label="可做城市" v-if="classIdFlg == '1'">
            <el-cascader :options="shopForm.sureCityArr" :props="{'multiple':true}" v-model="shopForm.sureCity" style="width:100%;"></el-cascader>
          </el-form-item>
          <el-form-item label="评估" v-if="classIdFlg == '1'">
            <el-input v-model="shopForm.assessment" placeholder="请输入评估方式或机构名称"></el-input>
          </el-form-item>
          <el-form-item label="抵押与借款关系" v-if="classIdFlg == '1'">
            <el-input v-model="shopForm.relationship" placeholder="请输入抵押与借款关系 例如：抵贷合一 或 朋友"></el-input>
          </el-form-item>
          <el-form-item label="优势" v-if="classIdFlg != '3' || classIdFlg != '5'">
            <el-input type="textarea" autosize v-model="shopForm.advantage" placeholder="请填写产品优势"></el-input>
          </el-form-item>
          <el-form-item label="劣势" v-if="classIdFlg != '3' || classIdFlg != '5'">
            <el-input type="textarea" autosize v-model="shopForm.inferiority" placeholder="请填写产品劣势"></el-input>
          </el-form-item>
          <el-form-item label="所需资料" v-if="classIdFlg == '2'">
            <el-input type="textarea" autosize v-model="shopForm.informationRequired" placeholder="请填写所需资料"></el-input>
          </el-form-item>
          <el-form-item label="成数" v-if="classIdFlg == '1'">
            <el-input v-model="shopForm.percentage" placeholder="例如：7成"></el-input>
          </el-form-item>
          <el-form-item label="平台费" v-if="classIdFlg == '1'">
            <el-input v-model="shopForm.platformFee"></el-input>
          </el-form-item>
          <el-form-item label="办理流程" v-if="classIdFlg == '5'">
            <el-input type="textarea" autosize v-model="shopForm.process" placeholder="请填写办理流程"></el-input>
          </el-form-item>
          <el-form-item label="备注">
            <el-input type="textarea" autosize v-model="shopForm.remarks" placeholder="请填写备注"></el-input>
          </el-form-item>
          <el-form-item label="产品标签">
            <el-checkbox-group v-model="shopForm.tags" size="mini" class="tagscheck" @change="tagsChange">
              <div :key="tagsArrLoad">
                <el-checkbox v-for="item in shopForm.tagsArr" :label="item.ptId" border>{{item.ptName}}</el-checkbox>
                <el-button type="text" icon="el-icon-refresh" :style="{marginLeft:'10px'}" @click="tagsArrPage">换一批</el-button>
              </div>
              <el-checkbox v-for="item in shopForm.tagsNewArr" :label="item.id" border>{{item.name}}</el-checkbox>
              <div>
                <el-button type="text" icon="el-icon-plus" @click="customClick">自定义</el-button>
                <div v-if="customFlg">
                  <el-input v-model="tagtext" maxlength="4" placeholder="请输入自定义名称" :style="{width:'300px',marginRight:'10px'}"></el-input>
                  <el-button type="text" :loading="customAddFlg" @click="customAddClick">添加</el-button>
                  <el-button type="text" @click="customNoClick">取消</el-button>
                </div>
              </div>

            </el-checkbox-group>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="addClickSub" :loading="shopFormSubFlg">保存</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-drawer>
    <!-- 产品图预览 -->
    <el-dialog :visible.sync="IMG_dialogVisible">
      <img width="100%" :src="IMG_dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>

<script>
import Storage from '../../../../utils/localStorage';
import CITYARRDATA from '../../../../utils/city';
import cosUpFile from '../../../../utils/cos';
import { productListGetClass, productListAddSub, productListEditInit, productListEditSub, classManageGetProductTable, classManageGetProductAddSub } from '../../../../api/index'

export default {
  data() {
    return {
      formDisabled: false,
      addShopDrawer: {
        addShopDrawerFlg: false
      },
      //产品图
      IMG_dialogImageUrl: '',
      IMG_dialogVisible: false,
      IMG_disabled: false,
      uploadHeader: { Authorization: Storage.getItem('token') ? Storage.getItem('token') : '1' },

      shopFormSubFlg: false,
      shopForm: {
        product_name: '',
        priductClassId: [],
        productImgView: [],
        loanMechanismName: '',
        userAge: [22, 55],
        userAgeMarks: {
          18: {
            label: this.$createElement('strong', '18')
          },
          22: {
            label: this.$createElement('strong', '22')
          },
          55: {
            label: this.$createElement('strong', '55')
          },
          60: {
            label: this.$createElement('strong', '60')
          }
        },
        importCondition: '',
        accumulationFundView: 1200,
        socialSecurityView: 3000,
        kilometreNum: '',
        wages: '',
        room: '',
        modelrq: '',
        carGPS: '',
        mortgageYears: '',
        interestRate: '',
        interestRateYearView: 1.4,
        interestRateMonthView: 0.03,
        interestRateText: '',
        projectApproval: '',
        quotaMin: '',
        quotaMax: '',
        quotaText: '',
        term: '',
        repaymentType: [],
        repaymentTypeArr: [
          {
            name: '先息后本',
            value: '1',
            text: ''
          },
          {
            name: '等额本息',
            value: '2',
            text: ''
          },
          {
            name: '停本付息',
            value: '3',
            text: ''
          },
          {
            name: '静息还款',
            value: '4',
            text: ''
          },
          {
            name: '等本等息',
            value: '5',
            text: ''
          },
          {
            name: '月息年本',
            value: '6',
            text: ''
          },
        ],
        loan: '',
        applicantRQ: '',
        enterpriseBilling: '',
        targetEnterprise: '',
        industryLimit: '',
        creditInvestigation: '',
        liabilities: '',
        sureCity: '',
        sureCityArr: CITYARRDATA,
        assessment: '',
        relationship: '',
        advantage: '',
        inferiority: '',
        informationRequired: '',
        percentage: '',
        platformFee: '无',
        process: '',
        remarks: '',
        tags: [],
        tagsArr: [],
        tagsNewArr: [],
        //分类
        priductClass: []
      },
      //换一批
      tagsArrLoad: false,
      //自定义标签
      customFlg: false,
      tagPage: 1,
      tagtext: '',
      customAddFlg: false,

      //分类展示表单项
      classIdFlg: "0",
      //修改id
      editId: '',
    }
  },
  created() {
    this.getProductClass();
    this.getTagList();
  },
  methods: {
    //获取产品分类
    getProductClass() {
      productListGetClass().then((res) => {
        if (res.code === 0) {
          let arr = [];
          res.list.forEach((item, i) => {
            arr.push({
              value: item.id,
              label: item.title
            })
            if (item.child && item.child.length > 0) {
              arr[i].children = [];
              item.child.forEach((e, index) => {
                arr[i].children.push({
                  value: e.id,
                  label: e.title
                })
                if (e.child && e.child.length > 0) {
                  arr[i].children[index].children = [];
                  e.child.forEach((ev, y) => {
                    arr[i].children[index].children.push({
                      value: ev.id,
                      label: ev.title
                    })
                  })
                }
              })
            }
          })
          this.shopForm.priductClass = arr;
        } else {
          this.$message(res.msg);
        }
      })
    },
    //获取标签
    getTagList() {
      classManageGetProductTable({ page: this.tagPage, limit: 10 }).then(res => {
        if (res.code == 0) {
          if (res.recordList.length > 0) {
            this.$set(this.shopForm, "tagsArr", res.recordList);
            this.tagsArrLoad = !this.tagsArrLoad;
          }
        } else {
          this.$message(res.msg);
        }
      })
    },
    //分类选中
    priductClassChange(val) {
      this.classIdFlg = val[0];
    },
    //新增
    addBtnClick() {
      this.editId = "";
      this.addShopDrawer.addShopDrawerFlg = true;
      let priductClass = this.shopForm.priductClass;
      this.shopForm = {
        product_name: '',
        priductClassId: [],
        productImgView: [],
        loanMechanismName: '',
        userAge: [22, 55],
        userAgeMarks: {
          18: {
            label: this.$createElement('strong', '18')
          },
          22: {
            label: this.$createElement('strong', '22')
          },
          55: {
            label: this.$createElement('strong', '55')
          },
          60: {
            label: this.$createElement('strong', '60')
          }
        },
        importCondition: '',
        accumulationFundView: 1200,
        socialSecurityView: 3000,
        kilometreNum: '',
        wages: '',
        room: '',
        modelrq: '',
        carGPS: '',
        mortgageYears: '',
        interestRate: '',
        interestRateYearView: 1.4,
        interestRateMonthView: 0.03,
        interestRateText: '',
        projectApproval: '',
        quotaMin: '',
        quotaMax: '',
        quotaText: '',
        term: '',
        repaymentType: [],
        repaymentTypeArr: [
          {
            name: '先息后本',
            value: '1',
            text: ''
          },
          {
            name: '等额本息',
            value: '2',
            text: ''
          },
          {
            name: '停本付息',
            value: '3',
            text: ''
          },
          {
            name: '静息还款',
            value: '4',
            text: ''
          },
          {
            name: '等本等息',
            value: '5',
            text: ''
          },
          {
            name: '月息年本',
            value: '6',
            text: ''
          },
        ],
        loan: '',
        applicantRQ: '',
        enterpriseBilling: '',
        targetEnterprise: '',
        industryLimit: '',
        creditInvestigation: '',
        liabilities: '',
        sureCity: '',
        sureCityArr: CITYARRDATA,
        assessment: '',
        relationship: '',
        advantage: '',
        inferiority: '',
        informationRequired: '',
        percentage: '',
        platformFee: '无',
        process: '',
        remarks: '',
        tags: [],
        tagsNewArr: [],
      };
      this.shopForm.priductClass = priductClass;
      this.customFlg = false;
      this.tagPage = 1;
      this.getTagList();
    },
    //新增提交
    addClickSub() {
      if (!this.shopForm.product_name) {
        this.$message("请填写产品名称");
        return false;
      }
      if (!this.shopForm.quotaMin) {
        this.$message("请填写最小额度");
        return false;
      }
      if (!this.shopForm.quotaMax) {
        this.$message("请填写最大额度");
        return false;
      }
      if (this.shopForm.repaymentType.length == 0) {
        this.$message("请选择还款方式");
        return false;
      }
      let that = this;
      this.shopFormSubFlg = true;
      let obj = {};
      //基本
      obj.pbId = this.editId;
      obj.pbName = this.shopForm.product_name;
      obj.pbPic = (() => {
        let arr = [];
        this.shopForm.productImgView.forEach(item => {
          arr.push(item.url);
        })
        return arr.join(',');
      })();
      obj.pbTypeId = this.shopForm.priductClassId[this.shopForm.priductClassId.length - 1];
      obj.parentTypeId = this.shopForm.priductClassId[0];
      obj.lenderId = this.shopForm.loanMechanismName;
      obj.borrowerMaxAge = this.shopForm.userAge[this.shopForm.userAge.length - 1];
      obj.borrowerMinAge = this.shopForm.userAge[0];
      obj.interestRateType = this.shopForm.interestRate;
      obj.interestRate = this.shopForm.interestRate == "1" ? this.shopForm.interestRateYearView : this.shopForm.interestRateMonthView;
      obj.interestRateRemarks = this.shopForm.interestRateText;
      obj.loan = this.shopForm.loan;
      obj.city = JSON.stringify(this.shopForm.sureCity);
      obj.good = this.shopForm.advantage;
      obj.bad = this.shopForm.inferiority;
      obj.quotaMin = this.shopForm.quotaMin;
      obj.quotaMax = this.shopForm.quotaMax;
      obj.quotaRemarks = this.shopForm.quotaText;
      obj.remarks = this.shopForm.remarks;
      obj.tagList = this.shopForm.tags;
      obj.percentage = this.shopForm.percentage;
      obj.enterCondition = this.shopForm.importCondition;
      obj.term = this.shopForm.term;
      obj.platformFee = this.shopForm.platformFee;
      obj.creditReferenceRequire = this.shopForm.creditInvestigation;
      obj.repaymentTypeList = (() => {
        let arr = [];
        that.shopForm.repaymentType.forEach((item, i) => {
          that.shopForm.repaymentTypeArr.forEach((e, index) => {
            if (item == e.value) {
              arr.push({
                rtType: e.value,
                rtRemarks: e.text
              })
            }
          })
        })
        return arr;
      })();
      if (this.classIdFlg == '1') {
        obj.productHouse = {};
        obj.productHouse.houseAge = this.shopForm.room;
        obj.productHouse.projectIdentification = this.shopForm.projectApproval;
        obj.productHouse.mortgagorPayerRelation = this.shopForm.relationship;
        obj.productHouse.phMortgageTerm = this.shopForm.mortgageYears;
        obj.productHouse.ratingAgency = this.shopForm.assessment;
      } else if (this.classIdFlg == '2') {
        obj.productCar = {};
        obj.productCar.kmNum = this.shopForm.kilometreNum;
        obj.productCar.carType = this.shopForm.modelrq;
        obj.productCar.gps = this.shopForm.carGPS;
        obj.productCar.pcMortgageTerm = this.shopForm.mortgageYears;
      } else if (this.classIdFlg == '3') {
        obj.productEnterprise = {};
        obj.productEnterprise.invoice = this.shopForm.enterpriseBilling;
        obj.productEnterprise.target = this.shopForm.targetEnterprise;
        obj.productEnterprise.industry = this.shopForm.industryLimit;
        obj.productEnterprise.liabilityCalculateType = this.shopForm.liabilities;
      } else if (this.classIdFlg == '4') {
        obj.productCred = {};
        obj.productCred.accumulationFund = this.shopForm.accumulationFundView;
        obj.productCred.socialSecurity = this.shopForm.socialSecurityView;
        obj.productCred.wages = this.shopForm.wages;
      } else if (this.classIdFlg == '5') {
        obj.productTax = {};
        obj.productTax.ptHandlingProcess = this.shopForm.process;
        obj.productTax.ptTarget = this.shopForm.targetEnterprise;
        obj.productTax.ptIndustry = this.shopForm.industryLimit;
      }
      if (this.editId) {
        productListEditSub(obj).then((res) => {
          this.shopFormSubFlg = false;
          if (res.code == 0) {
            this.$message.success('修改成功');
            this.addShopDrawer.addShopDrawerFlg = false;
            this.$emit('getTable');
          } else {
            this.$message(res.msg);
          }
        })
      } else {
        productListAddSub(obj).then((res) => {
          this.shopFormSubFlg = false;
          if (res.code == 0) {
            this.$message.success('新增成功');
            this.addShopDrawer.addShopDrawerFlg = false;
            this.$emit('getTable');
          } else {
            this.$message(res.msg);
          }
        })
      }
    },
    //编辑初始化
    editInit(id, flg) {
      if (flg == 'browse') {
        this.formDisabled = true;
      } else {
        this.formDisabled = false;
      }
      this.editId = id;
      this.addShopDrawer.addShopDrawerFlg = true;
      productListEditInit({ pbId: id }).then((res) => {
        if (res.code == 0) {
          this.shopForm.product_name = res.product.pbName;

          //产品分类
          // this.classIdFlg = res.product.parentTypeId;
          this.shopForm.priductClassId = [];
          this.shopForm.priductClass.forEach((item, i) => {
            if (item.value == res.product.pbTypeId) {
              this.shopForm.priductClassId.push(item.value);

              this.classIdFlg = item.value;
            } else {
              if (item.children && item.children.length > 0) {
                item.children.forEach((e, index) => {
                  if (e.value == res.product.pbTypeId) {
                    this.shopForm.priductClassId.push(item.value);
                    this.shopForm.priductClassId.push(e.value);

                    this.classIdFlg = item.value;
                  } else {
                    if (e.children && e.children.length > 0) {
                      e.children.forEach((ev, y) => {
                        if (ev.value == res.product.pbTypeId) {
                          this.shopForm.priductClassId.push(item.value);
                          this.shopForm.priductClassId.push(e.value);
                          this.shopForm.priductClassId.push(ev.value);

                          this.classIdFlg = item.value;
                        }
                      })
                    }
                  }
                })
              }
            }
          })
          //产品图
          this.shopForm.productImgView = [];
          if (res.product.pbPic) {
            res.product.pbPic.split(",").forEach((item, i) => {
              this.shopForm.productImgView.push({
                name: '1',
                url: item,
              })
            })
          }

          this.shopForm.loanMechanismName = res.product.lenderId;
          this.shopForm.userAge = [];
          this.shopForm.userAge[0] = res.product.borrowerMinAge;
          this.shopForm.userAge[1] = res.product.borrowerMaxAge;
          this.shopForm.interestRate = res.product.interestRateType;
          this.shopForm.interestRateYearView = res.product.interestRateType == "1" ? res.product.interestRate : 1;
          this.shopForm.interestRateMonthView = res.product.interestRateType == "2" ? res.product.interestRate : 0;
          this.shopForm.interestRateText = res.product.interestRateRemarks;
          this.shopForm.loan = res.product.loan;
          this.shopForm.sureCity = JSON.parse(res.product.city);
          this.shopForm.advantage = res.product.good;
          this.shopForm.inferiority = res.product.bad;
          this.shopForm.quotaMin = res.product.quotaMin;
          this.shopForm.quotaMax = res.product.quotaMax;
          this.shopForm.quotaText = res.product.quotaRemarks;
          this.shopForm.remarks = res.product.remarks;
          this.shopForm.tags = res.tagList ? res.tagList : [];
          this.shopForm.percentage = res.product.percentage;
          this.shopForm.importCondition = res.product.enterCondition;
          this.shopForm.term = res.product.term;
          this.shopForm.platformFee = res.product.platformFee;
          this.shopForm.creditInvestigation = res.product.creditReferenceRequire;

          //还款方式
          this.shopForm.repaymentType = [];
          if (res.repaymentTypeList) {
            res.repaymentTypeList.forEach((item, i) => {
              this.shopForm.repaymentType.push(item.rtType);
              this.shopForm.repaymentTypeArr.forEach((e, index) => {
                if (item.rtType == e.value) {
                  this.shopForm.repaymentTypeArr[index].text = item.rtRemarks;
                }
              })
            })
          }

          if (res.product.productHouse) {
            this.shopForm.room = res.product.productHouse.houseAge;
            this.shopForm.projectApproval = res.product.productHouse.projectIdentification;
            this.shopForm.relationship = res.product.productHouse.mortgagorPayerRelation;
            this.shopForm.mortgageYears = res.product.productHouse.ph_mortgage_term;
            this.shopForm.assessment = res.product.productHouse.rating_agency;
          }
          if (res.product.productCar) {
            this.shopForm.kilometreNum = res.product.productCar.kmNum;
            this.shopForm.modelrq = res.product.productCar.carType;
            this.shopForm.carGPS = res.product.productCar.gps;
            this.shopForm.mortgageYears = res.product.productCar.pc_mortgage_term;
          }
          if (res.product.productEnterprise) {
            this.shopForm.enterpriseBilling = res.product.productEnterprise.invoice;
            this.shopForm.targetEnterprise = res.product.productEnterprise.target;
            this.shopForm.industryLimit = res.product.productEnterprise.industry;
            this.shopForm.liabilities = res.product.productEnterprise.liabilityCalculateType;
          }
          if (res.product.productCred) {
            this.shopForm.accumulationFundView = res.product.productCred.accumulationFund;
            this.shopForm.socialSecurityView = res.product.productCred.socialSecurity;
            this.shopForm.wages = res.product.productCred.wages;
          }
          if (res.product.productTax) {
            this.shopForm.process = res.product.productTax.ptHandlingProcess;
            this.shopForm.targetEnterprise = res.product.productTax.ptTarget;
            this.shopForm.industryLimit = res.product.productTax.ptIndustry;
          }
        } else {
          this.$message(res.msg);
        }
      })
    },
    //换一批
    tagsArrPage() {
      this.tagPage++;
      this.getTagList();
    },
    //点击自定义
    customClick() {
      this.customFlg = true;
    },
    //自定义标签提交
    customAddClick() {
      this.customAddFlg = true;
      classManageGetProductAddSub({ name: this.tagtext }).then(res => {
        this.customAddFlg = false;
        if (res.code == 0) {
          this.shopForm.tagsNewArr.push({
            name: res.tag.ptName,
            id: res.tag.ptId
          })
          this.customFlg = false;
          this.tagtext = '';
        } else {
          this.$message(res.msg);
        }
      })
    },
    //自定义标签取消
    customNoClick() {
      this.customFlg = false;
    },
    //选中标签
    tagsChange() {
      if (this.shopForm.tags.length > 2) {
        this.$message('最多选择两项');
        this.shopForm.tags.pop();
      }
    },
    //上传产品图
    IMG_upload(file) {
      cosUpFile(file, (err, data) => {
        if (err) {
          this.$message('上传出错');
        }
        if (data) {
          this.shopForm.productImgView.push({ name: '', url: 'https://' + data.Location });
        }
      })
      return false;
    },
    //删除产品图
    IMG_handleRemove(file) {
      let removeUrl = file.response.path;
      this.$refs.upload.uploadFiles.forEach((item, i) => {
        if (item.response.path == removeUrl) {
          this.$refs.upload.uploadFiles.splice(i, 1);
          this.shopForm.productImgView.splice(i, 1);
        }
      })
    },
    //放大产品图
    IMG_handlePictureCardPreview(file) {
      this.IMG_dialogImageUrl = file.url;
      this.IMG_dialogVisible = true;
    },
    //公积金取值
    accumulationFundTooltip(val) {
      return val + ' 以上';
    },
    //社保取值
    socialSecurityTooltip(val) {
      return val + ' 以上';
    },
    //年利率
    interestRateYearViewTooltip(val) {
      return val + '%';
    },
    //月利率
    interestRateMonthViewTooltip(val) {
      return val + '%';
    },
  }
}
</script>

<style scoped>
/deep/ :focus {
    outline: 0;
}
.nameDrawer {
    padding: 30px;
}
.el-input__inner {
    width: 300px;
}
.shopFormMar {
    margin-bottom: 10px;
}
.shopFormMar label {
    line-height: 32px;
}
.tagscheck >>> .el-checkbox__input {
    opacity: 0;
    margin-left: -10px;
}
.tagscheck >>> .el-checkbox.is-bordered.el-checkbox--mini {
    padding: 3px 10px;
    margin-right: 0;
}
.tagscheck >>> .el-checkbox.is-bordered.el-checkbox--mini .el-checkbox__label {
    padding-left: 0;
}
</style>